package com.kai.steering.data.service.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import com.kai.steering.data.service.entity.domainObject.TestDO;
import lombok.*;

import java.io.Serializable;
import java.util.stream.Collectors;

/**
 * <pre>
 * 试卷
 * </pre>
 *
 * @author kai
 * @since 2022-02-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@TableName(value = "test")

public class Test implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 试卷id
     */
    @TableId(value = "test_id", type = IdType.ID_WORKER)

    private String testId;


    /**
     * 试卷名
     */

    private String testName;


    /**
     * 管理员id或者用户id
     */

    private String founder;


    /**
     * 对试卷的介绍
     */

    private String testInformation;


    /**
     * 创建时间
     */

    private Date creationDatetime;

    /**
     * 知识点 以;作为分割
     */

    private String knowledgeId;


    /**
     * 存在0删除1
     */

    private Integer usable;


    /**
     * 删除日期
     */

    private Date deleteDatetime;


    public Test(TestDO testDO) {
        this.testId=testDO.getTestId();
        this.testName=testDO.getTestName();
        this.founder=testDO.getFounder();
        this.testInformation=testDO.getTestInformation();
        this.creationDatetime=testDO.getCreationDatetime();
        if (testDO.getKnowledgeDOs()!=null){
            this.knowledgeId=testDO.getKnowledgeDOs().stream().map(knowledgeDO -> {
                return knowledgeDO.getKnowledgeId();
            }).collect(Collectors.joining(","));
        }

        this.usable=testDO.getUsable();
        this.deleteDatetime=testDO.getDeleteDatetime();
    }
}
